home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / dmmde321.zip / MONSTERS.QC < prev    next >
Text File  |  1996-02-08  |  5KB  |  237 lines

  1. /* ALL MONSTERS SHOULD BE 1 0 0 IN COLOR */
  2.  
  3. // name =[framenum,    nexttime, nextthink] {code}
  4. // expands to:
  5. // name ()
  6. // {
  7. //        self.frame=framenum;
  8. //        self.nextthink = time + nexttime;
  9. //        self.think = nextthink
  10. //        <code>
  11. // };
  12.  
  13.  
  14. /*
  15. ================
  16. monster_use
  17.  
  18. Using a monster makes it angry at the current activator
  19. ================
  20. */
  21. void() monster_use =
  22. {
  23.     if (self.enemy)
  24.         return;
  25.     if (self.health <= 0)
  26.         return;
  27.     if (activator.items & IT_INVISIBILITY)
  28.         return;
  29.     if (activator.flags & FL_NOTARGET)
  30.         return;
  31.     if (activator.classname != "player")
  32.         return;
  33.     
  34. // delay reaction so if the monster is teleported, its sound is still
  35. // heard
  36.     self.enemy = activator;
  37.     self.nextthink = time + 0.1;
  38.     self.think = FoundTarget;
  39. };
  40.  
  41. /*
  42. ================
  43. monster_death_use
  44.  
  45. When a mosnter dies, it fires all of its targets with the current
  46. enemy as activator.
  47. ================
  48. */
  49. void() monster_death_use =
  50. {
  51.     local entity     ent, otemp, stemp;
  52.  
  53. // fall to ground
  54.     if (self.flags & FL_FLY)
  55.         self.flags = self.flags - FL_FLY;
  56.     if (self.flags & FL_SWIM)
  57.         self.flags = self.flags - FL_SWIM;
  58.  
  59.     if (!self.target)
  60.         return;
  61.  
  62.     activator = self.enemy;
  63.     SUB_UseTargets ();
  64. };
  65.  
  66.  
  67. //============================================================================
  68.  
  69. void() walkmonster_start_go =
  70. {
  71. local string    stemp;
  72. local entity    etemp;
  73.  
  74.     self.origin_z = self.origin_z + 1;    // raise off floor a bit
  75.     droptofloor();
  76.     
  77.     if (!walkmove(0,0))
  78.     {
  79.         dprint ("walkmonster in wall at: ");
  80.         dprint (vtos(self.origin));
  81.         dprint ("\n");
  82.     }
  83.     
  84.     self.takedamage = DAMAGE_AIM;
  85.  
  86.     self.ideal_yaw = self.angles * '0 1 0';
  87.     if (!self.yaw_speed)
  88.         self.yaw_speed = 20;
  89.     self.view_ofs = '0 0 25';
  90.     self.use = monster_use;
  91.     
  92.     self.flags = self.flags | FL_MONSTER;
  93.     
  94.     if (self.target)
  95.     {
  96.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  97.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  98.         if (!self.movetarget)
  99.         {
  100.             dprint ("Monster can't find target at ");
  101.             dprint (vtos(self.origin));
  102.             dprint ("\n");
  103.         }
  104. // this used to be an objerror
  105.         if (self.movetarget.classname == "path_corner")
  106.             self.th_walk ();
  107.         else
  108.             self.pausetime = 99999999;
  109.             self.th_stand ();
  110.     }
  111.     else
  112.     {
  113.         self.pausetime = 99999999;
  114.         self.th_stand ();
  115.     }
  116.  
  117. // spread think times so they don't all happen at same time
  118.     self.nextthink = self.nextthink + random()*0.5;
  119. };
  120.  
  121.  
  122. void() walkmonster_start =
  123. {
  124. // delay drop to floor to make sure all doors have been spawned
  125. // spread think times so they don't all happen at same time
  126.     self.nextthink = self.nextthink + random()*0.5;
  127.     self.think = walkmonster_start_go;
  128.     total_monsters = total_monsters + 1;
  129. };
  130.  
  131.  
  132.  
  133. void() flymonster_start_go =
  134. {
  135.     self.takedamage = DAMAGE_AIM;
  136.  
  137.     self.ideal_yaw = self.angles * '0 1 0';
  138.     if (!self.yaw_speed)
  139.         self.yaw_speed = 10;
  140.     self.view_ofs = '0 0 25';
  141.     self.use = monster_use;
  142.  
  143.     self.flags = self.flags | FL_FLY;
  144.     self.flags = self.flags | FL_MONSTER;
  145.  
  146.     if (!walkmove(0,0))
  147.     {
  148.         dprint ("flymonster in wall at: ");
  149.         dprint (vtos(self.origin));
  150.         dprint ("\n");
  151.     }
  152.  
  153.     if (self.target)
  154.     {
  155.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  156.         if (!self.movetarget)
  157.         {
  158.             dprint ("Monster can't find target at ");
  159.             dprint (vtos(self.origin));
  160.             dprint ("\n");
  161.         }
  162. // this used to be an objerror
  163.         if (self.movetarget.classname == "path_corner")
  164.             self.th_walk ();
  165.         else
  166.             self.pausetime = 99999999;
  167.             self.th_stand ();
  168.     }
  169.     else
  170.     {
  171.         self.pausetime = 99999999;
  172.         self.th_stand ();
  173.     }
  174. };
  175.  
  176. void() flymonster_start =
  177. {
  178. // spread think times so they don't all happen at same time
  179.     self.nextthink = self.nextthink + random()*0.5;
  180.     self.think = flymonster_start_go;
  181.     total_monsters = total_monsters + 1;
  182. };
  183.  
  184.  
  185. void() swimmonster_start_go =
  186. {
  187.         if ((deathmatch) && (deathmatch > 3))
  188.     {
  189.         remove(self);
  190.         return;
  191.     }
  192.  
  193.     self.takedamage = DAMAGE_AIM;
  194.     total_monsters = total_monsters + 1;
  195.  
  196.     self.ideal_yaw = self.angles * '0 1 0';
  197.     if (!self.yaw_speed)
  198.         self.yaw_speed = 10;
  199.     self.view_ofs = '0 0 10';
  200.     self.use = monster_use;
  201.     
  202.     self.flags = self.flags | FL_SWIM;
  203.     self.flags = self.flags | FL_MONSTER;
  204.  
  205.     if (self.target)
  206.     {
  207.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  208.         if (!self.movetarget)
  209.         {
  210.             dprint ("Monster can't find target at ");
  211.             dprint (vtos(self.origin));
  212.             dprint ("\n");
  213.         }
  214. // this used to be an objerror
  215.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  216.         self.th_walk ();
  217.     }
  218.     else
  219.     {
  220.         self.pausetime = 99999999;
  221.         self.th_stand ();
  222.     }
  223.  
  224. // spread think times so they don't all happen at same time
  225.     self.nextthink = self.nextthink + random()*0.5;
  226. };
  227.  
  228. void() swimmonster_start =
  229. {
  230. // spread think times so they don't all happen at same time
  231.     self.nextthink = self.nextthink + random()*0.5;
  232.     self.think = swimmonster_start_go;
  233.     total_monsters = total_monsters + 1;
  234. };
  235.  
  236.  
  237.